//
//  WNBaseNaviVC.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/4.
//

import UIKit

class WNBaseNaviVC: UINavigationController, UINavigationControllerDelegate {
    /// 滑动手势
    weak var popDelegate: UIGestureRecognizerDelegate?
    
    override init(rootViewController: UIViewController) {
        super.init(rootViewController: rootViewController)
        // 使用后屏幕侧滑功能失效
        isNavigationBarHidden = true
    }
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        popDelegate = interactivePopGestureRecognizer?.delegate
        delegate = self
    }
    
    func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
        if viewController == viewControllers[0] {
            interactivePopGestureRecognizer?.delegate = popDelegate
        }else{
            interactivePopGestureRecognizer?.delegate = nil
        }
    }
}
